<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Jumper documentation</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Jumper(v1.8.1)</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
</ul>


<h2>Modules</h2>
<ul>
  <li><a href="../modules/jumper.core.bheap.html">jumper.core.bheap</a></li>
  <li><a href="../modules/jumper.core.heuristics.html">jumper.core.heuristics</a></li>
  <li><a href="../modules/jumper.core.node.html">jumper.core.node</a></li>
  <li><a href="../modules/jumper.core.path.html">jumper.core.path</a></li>
  <li><strong>jumper.grid</strong></li>
  <li><strong>jumper.grid</strong></li>
  <li><a href="../modules/jumper.pathfinder.html">jumper.pathfinder</a></li>
</ul>
<h2>Scripts</h2>
<ul>
  <li><a href="../scripts/jumper.search.astar.html">jumper.search.astar</a></li>
  <li><a href="../scripts/jumper.search.bfs.html">jumper.search.bfs</a></li>
  <li><a href="../scripts/jumper.search.dfs.html">jumper.search.dfs</a></li>
  <li><a href="../scripts/jumper.search.dijkstra.html">jumper.search.dijkstra</a></li>
  <li><a href="../scripts/jumper.search.jps.html">jumper.search.jps</a></li>
  <li><a href="../scripts/jumper.search.thetastar.html">jumper.search.thetastar</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>jumper.grid</code></h1>

<p><strong>The <code>grid</code> class API</strong>.</p>
<p> Implementation of a <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  class, which represents the 2D map (graph) on which a <a href="../modules/jumper.grid.html#jumper.pathfinder">pathfinder</a>  will perform.</p>

<p> During a search, the pathfinder evaluates <strong>costs values</strong> for each node being processed, in order to
 select, after each step of iteration, what node should be expanded next to reach the target
 optimally. Those values are cached within an array of nodes inside the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object.</p>
    <h3>Usage:</h3>
    <ul>
        <pre class="example">-- Usage Example
-- First, set a collision map
local map = {
	{0,1,0,1,0},
	{0,1,0,1,0},
	{0,1,1,1,0},
	{0,0,0,0,0},
}
-- Value for walkable tiles
local walkable = 0

-- Library setup
local Grid = require (&quot;jumper.grid&quot;) -- The grid class

-- Creates a grid object
local grid = Grid(map)
</pre>
    </ul>
    <h3>Info:</h3>
    <ul>
        <li><strong>Copyright</strong>: 2012-2013</li>
        <li><strong>License</strong>: <a href="http://www.opensource.org/licenses/mit-license.php">MIT</a></li>
        <li><strong>Author</strong>: Roland Yonaba</li>
    </ul>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid:new">grid:new&nbsp;(map[, processOnDemand])</a></td>
	<td class="summary">Inits a new <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:isWalkableAt">grid:isWalkableAt&nbsp;(x, y, walkable)</a></td>
	<td class="summary">Checks walkability.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getWidth">grid:getWidth&nbsp;()</a></td>
	<td class="summary">Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  width.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getHeight">grid:getHeight&nbsp;()</a></td>
	<td class="summary">Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  height.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getMap">grid:getMap&nbsp;()</a></td>
	<td class="summary">Gets the collision map.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNodes">grid:getNodes&nbsp;()</a></td>
	<td class="summary">Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  nodes.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNeighbours">grid:getNeighbours&nbsp;(node, walkable[, allowDiagonal[, tunnel]])</a></td>
	<td class="summary">Returns the neighbours of a given <code>node</code> on a <a href="../modules/jumper.grid.html#jumper.grid">grid</a> </td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:iter">grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</a></td>
	<td class="summary">Iterates on nodes on the grid.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:each">grid:each&nbsp;(f[, ...])</a></td>
	<td class="summary">Each transformation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:eachRange">grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Each in range transformation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imap">grid:imap&nbsp;(f[, ...])</a></td>
	<td class="summary">Map transformation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:imapRange">grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</a></td>
	<td class="summary">Map in range transformation.</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#grid:getNodeAt">grid:getNodeAt&nbsp;(x, y)</a></td>
	<td class="summary">Returns the <code>node</code>[x,y] on a <a href="../modules/jumper.grid.html#jumper.grid">grid</a> .</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#grid">grid</a></td>
	<td class="summary">The <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  class</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>

    <dl class="function">
    <dt>
    <a name = "grid:new"></a>
    <strong>grid:new&nbsp;(map[, processOnDemand])</strong>
    </dt>
    <dd>
    Inits a new <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">map</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
       A collision map - (2D array) with consecutive integer indices or a string with line-break symbol as a row delimiter.</li>
      <li><span class="parameter">processOnDemand</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not caching nodes in the internal grid should be processed on-demand</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><a class="type" href="../modules/jumper.grid.html#jumper.grid">grid</a></span>
        a new <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object
    </ol>




</dd>
    <dt>
    <a name = "grid:isWalkableAt"></a>
    <strong>grid:isWalkableAt&nbsp;(x, y, walkable)</strong>
    </dt>
    <dd>
    Checks walkability.  Tests if <code>node</code> [x,y] exists on the collision map and is walkable

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate of the node</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate of the node</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
       the value for walkable nodes on the passed-in map array.
 If this parameter is a function, it should be prototyped as <code>f(value)</code>, returning a boolean:
 <code>true</code> when value matches a <em>walkable</em> node, <code>false</code> otherwise. If this parameter is not given and
 node [x,y] exists, this function return <code>true</code>.</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">bool</span></span>
        <code>true</code> if the node exist and is walkable, <code>false</code> otherwise
    </ol>




</dd>
    <dt>
    <a name = "grid:getWidth"></a>
    <strong>grid:getWidth&nbsp;()</strong>
    </dt>
    <dd>
    Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  width.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">int</span></span>
        the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object width
    </ol>




</dd>
    <dt>
    <a name = "grid:getHeight"></a>
    <strong>grid:getHeight&nbsp;()</strong>
    </dt>
    <dd>
    Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  height.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">int</span></span>
        the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object height
    </ol>




</dd>
    <dt>
    <a name = "grid:getMap"></a>
    <strong>grid:getMap&nbsp;()</strong>
    </dt>
    <dd>
    Gets the collision map.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{{value},...}</span></span>
        the collision map previously passed to the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  object on initalization
    </ol>




</dd>
    <dt>
    <a name = "grid:getNodes"></a>
    <strong>grid:getNodes&nbsp;()</strong>
    </dt>
    <dd>
    Gets the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  nodes.


    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{{node},...}</span></span>
        the <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  nodes
    </ol>




</dd>
    <dt>
    <a name = "grid:getNeighbours"></a>
    <strong>grid:getNeighbours&nbsp;(node, walkable[, allowDiagonal[, tunnel]])</strong>
    </dt>
    <dd>
    Returns the neighbours of a given <code>node</code> on a <a href="../modules/jumper.grid.html#jumper.grid">grid</a>

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">node</span>
        <span class="types"><span class="type">node</span></span>
       <code>node</code> object</li>
      <li><span class="parameter">walkable</span>
        <span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string</a>, <span class="type">int</span> or <span class="type">function</span></span>
       the value for walkable nodes on the passed-in map array.
 If this parameter is a function, it should be prototyped as <code>f(value)</code>, returning a boolean:
 <code>true</code> when value matches a <em>walkable</em> node, <code>false</code> otherwise.</li>
      <li><span class="parameter">allowDiagonal</span>
        <span class="types"><span class="type">bool</span></span>
       whether or not adjacent nodes (8-directions moves) are allowed</li>
      <li><span class="parameter">tunnel</span>
        <span class="types"><span class="type">bool</span></span>
       Whether or not the pathfinder can tunnel though walls diagonally</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">{node,...}</span></span>
        an array of nodes neighbouring a passed-in node on the collision map
    </ol>




</dd>
    <dt>
    <a name = "grid:iter"></a>
    <strong>grid:iter&nbsp;([lx[, ly[, ex[, ey]]]])</strong>
    </dt>
    <dd>
    Iterates on nodes on the grid.  When given no args, will iterate on every single node
 on the grid, in case the grid is pre-processed. Passing <code>lx, ly, ex, ey</code> args will iterate
 on nodes inside a bounding-rectangle delimited by those coordinates.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">node</span></span>
        a node on the collision map, upon each iteration step
    </ol>




</dd>
    <dt>
    <a name = "grid:each"></a>
    <strong>grid:each&nbsp;(f[, ...])</strong>
    </dt>
    <dd>
    Each transformation.  Executes a function on each <code>node</code> in the <a href="../modules/jumper.grid.html#jumper.grid">grid</a> , passing the <code>node</code> as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:eachRange"></a>
    <strong>grid:eachRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Each in range transformation.  Executes a function on each <code>node</code> in the range of a rectangle of cells, passing the <code>node</code> as the first arg to function <code>f</code>.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imap"></a>
    <strong>grid:imap&nbsp;(f[, ...])</strong>
    </dt>
    <dd>
    Map transformation.  Maps function <code>f(node,...)</code> on each <code>node</code> in a given range, passing the <code>node</code> as the first arg to function <code>f</code>. The passed-in function should return a <code>node</code> object.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:imapRange"></a>
    <strong>grid:imapRange&nbsp;(lx, ly, ex, ey, f[, ...])</strong>
    </dt>
    <dd>
    Map in range transformation.  Maps <code>f(node,...)</code> on each <code>nod</code>e in the range of a rectangle of cells, passing the <code>node</code> as the first arg to function <code>f</code>. The passed-in function should return a <code>node</code> object.

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">lx</span>
        <span class="types"><span class="type">int</span></span>
       the leftmost x-coordinate coordinate of the rectangle</li>
      <li><span class="parameter">ly</span>
        <span class="types"><span class="type">int</span></span>
       the topmost y-coordinate of the rectangle</li>
      <li><span class="parameter">ex</span>
        <span class="types"><span class="type">int</span></span>
       the rightmost x-coordinate of the rectangle</li>
      <li><span class="parameter">ey</span>
        <span class="types"><span class="type">int</span></span>
       the bottom-most y-coordinate of the rectangle</li>
      <li><span class="parameter">f</span>
        <span class="types"><span class="type">function</span></span>
       a function prototyped as <code>f(node,...)</code></li>
      <li><span class="parameter">...</span>
        <span class="types"><span class="type">vararg</span></span>
       args to be passed to function <code>f</code></li>
    </ul>





</dd>
    <dt>
    <a name = "grid:getNodeAt"></a>
    <strong>grid:getNodeAt&nbsp;(x, y)</strong>
    </dt>
    <dd>
    Returns the <code>node</code>[x,y] on a <a href="../modules/jumper.grid.html#jumper.grid">grid</a> .

    <h3>Parameters:</h3>
    <ul>
      <li><span class="parameter">x</span>
        <span class="types"><span class="type">int</span></span>
       the x-coordinate coordinate</li>
      <li><span class="parameter">y</span>
        <span class="types"><span class="type">int</span></span>
       the y-coordinate coordinate</li>
    </ul>

    <h3>Returns:</h3>
    <ol>

          <span class="types"><span class="type">node</span></span>
        a <code>node</code> object
 Gets the node at location <x,y> on a preprocessed grid
    </ol>




</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>

    <dl class="function">
    <dt>
    <a name = "grid"></a>
    <strong>grid</strong>
    </dt>
    <dd>
    The <a href="../modules/jumper.grid.html#jumper.grid">grid</a>  class

    <h3>Fields:</h3>
    <ul>
      <li><span class="parameter">width</span>
       The grid width</li>
      <li><span class="parameter">height</span>
       The grid height</li>
      <li><span class="parameter">map</span>
       A reference to the collision map</li>
      <li><span class="parameter">nodes</span>
       A 2D array of nodes, each node matching a cell on the collision map</li>
    </ul>





</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.3</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
